VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "TestXMLNotifierTestResult"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Private mNotifier As XMLNotifierTestResult
Private mFine As Document
Private mAssert As New LocalAssertions
Private mResultPrimitive As New ResultPrimitive

Public Sub testFailXML()
givenNotifier
whenTestResultFail
thenXMLIs failXML
End Sub
Public Sub testIsTrueXML()
givenNotifier
whenTestResultIsTrue
thenXMLIs isTrueXML
End Sub
'' Helper methods to create XML
Private Function failXML() As String
Dim f As Document
Dim a As Document
Set f = NewDocument("finemethod")
Set a = f.addChild("assert")
a.createAttribute "passed", False
a.createAttribute "message", "msg"
a.addText "Fail"
failXML = f.xml
End Function
Private Function isTrueXML() As String
Dim f As Document
Dim a As Document
Set f = NewDocument("finemethod")
Set a = f.addChild("assert")
a.createAttribute "passed", True
a.createAttribute "message", "msg"
addExpected a, True
addActual a, True
a.addText "Actual was true"
isTrueXML = f.xml
End Function
Private Sub addExpected(a As Document, value As Variant)
Dim c As Document
Set c = a.addChild("expected")
c.addText Str(value)
End Sub
Private Sub addActual(a As Document, value As Variant)
Dim c As Document
Set c = a.addChild("actual")
c.addText Str(value)
End Sub

''
Private Sub givenNotifier()
Dim i As init
Set mFine = NewDocument("finemethod")
Set mNotifier = New XMLNotifierTestResult
mNotifier.init mFine
Set i = mAssert
i.init mResultPrimitive
mResultPrimitive.setNotification mNotifier
End Sub

Private Sub whenTestResultFail()
On Error Resume Next
mAssert.Fail "msg"
End Sub
Private Sub whenTestResultIsTrue()
On Error Resume Next
mAssert.isTrue True, "msg"
End Sub

Private Sub thenXMLIs(xml As String)
assert.equals mFine.xml, xml
End Sub

'OPTIONAL METHODS
Public Function NumOfAsserts() As Long
NumOfAsserts = 2
End Function

